package com.avic.map.common.convertor;


import com.avic.map.common.constant.AppConstant;
import com.avic.map.controller.info.SingleSoldierResourceListInfo;
import com.avic.map.dal.model.SingleSoldierResource;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 单兵资源对象转换器
 */
public class SingleSoldierResourceConvertor {


    /**
     * 将 pageSystemUser 转换为 SystemUserInfo
     *
     * @author: huangsheng
     * @date: 2017/10/20 下午2:00
     */
    public static List<SingleSoldierResourceListInfo> SingleSoldierListToSingleSoldierListInfoList(List<SingleSoldierResource> singleSoldiers) {
        if (null != singleSoldiers && singleSoldiers.size() > 0) {
            List<SingleSoldierResourceListInfo> singleSoldierListInfos = new ArrayList<>();
            singleSoldiers.forEach(singleSoldier -> {
                SingleSoldierResourceListInfo singleSoldierListInfo = new SingleSoldierResourceListInfo();
                singleSoldierListInfo.setId(singleSoldier.getId());
                singleSoldierListInfo.setPersonnelCompany(singleSoldier.getPersonnelCompany());
                singleSoldierListInfo.setPersonnelNumber(singleSoldier.getPersonnelNumber());
                singleSoldierListInfo.setCallSign(singleSoldier.getCallSign());
                singleSoldierListInfo.setEquipmentType(singleSoldier.getEquipmentType());
                singleSoldierListInfo.setCreateTime(StringUtils.isNotBlank(singleSoldier.getCreateTime()) ?
                        StringUtils.substringBefore(singleSoldier.getCreateTime(), AppConstant.MYBATIS_DATA_TIME_SEPARATOR) : StringUtils.EMPTY);
                singleSoldierListInfo.setVideoAddress(singleSoldier.getVideoAddress());
                singleSoldierListInfos.add(singleSoldierListInfo);
            });
            return singleSoldierListInfos;
        }
        return new ArrayList<>();
    }
}
